﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CyrideTest
{
    public partial class BusTime : Form
    {
        MainPage main;
        Location location;
        public BusTime(MainPage mainP, Location locationP)
        {
            InitializeComponent();
            main = mainP;
            location = locationP;
            lblLocation.Text = locationP.getName();
            cboRoute.DataSource = locationP.getBusRoutes();
        }

        private void Back_OnClick(object sender, EventArgs e)
        {
            main.Show();
            this.Close();
        }

        private void cboRoute_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstTime.Items.Clear();
            string selectedRoute = cboRoute.SelectedItem.ToString();
            location.selectedRoute(selectedRoute);
            foreach (TimeSpan s in location.getTimes())
            {
                if (s.CompareTo(DateTime.Now.TimeOfDay) > 0)
                {
                    lstTime.Items.Add(s.ToString());
                }
            }
        }

    }
}